<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Assignemnt 5</title>
</head>
<body>
<%!int count = 1;%>
<%
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	if (username==null && password==null ) {
%>
<form method="post" >
<table>
	<tr>
		<td>Username</td>
		<td><input type="text" name="username" /></td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="password" name="password" /></td>
	</tr>
	<tr>
		<td><input type="submit" value="Submit" /></td>
		<td><input type="reset" value="Reset" /></td>
	</tr>
</table>
</form>
<%
	} else {
		if (username.equals("admin") && password.equals("admin")) {
			response.sendRedirect("d3a5-welcome.jsp");
		} else {
			if (count < 3) {
%>
<form method="post">
<table>
	<tr>
		<td>Username</td>
		<td><input type="text" name="username" /></td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="password" name="password" /></td>
	</tr>
	<tr>
		<td colspan="2">Wrong credentials entered Please Try Again</td>
		<%
			count++;
		%>
	</tr>
	<tr>
		<td><input type="submit" value="Submit" /></td>
		<td><input type="reset" value="Reset" /></td>
	</tr>
</table>
</form>
<%
	} else
				out.write("<h2>access denies</h2>");
		}
	}
%>
</body>
</html>